<template>
	<view class="StoreAddress">
		<u-navbar title="">
			<view class="preservationBtn" slot="right" @click="preservationBtn">保存</view>
		</u-navbar>
		<view class="StoreAddressBox">
			<view class="toStoreAddressItem">
				<view class="addresstitle">地区</view>
				<view class="addressNameBox" @click="showRegion=true">
					<view class="addressName">{{region?region:"请选择"}}</view>
					<u-icon name="arrow-right" color="#BFBFBF" size="25"></u-icon>
				</view>
			</view>
			<view class="pickerBox">
				<u-picker mode="region" v-model="showRegion" @confirm="selectRegion"></u-picker>
			</view>
			<view class="specificAddressBox">
				<view class="specifictitle">详细地址：</view>
				<view class="inputBox">
					<input type="text" placeholder="请输入详细地址" v-model="address"/>
				</view>
			</view>
		</view>
		<view>
			<u-toast ref="uToast" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showRegion:false,
				region:"",
				address:"",
			}
		},
		methods: {
			//选择地区
			selectRegion(e){
				// console.log(e);
				this.region = e.province.label+e.city.label+e.area.label
			},
			//保存
			preservationBtn(){
				// alert(this.region+this.address)
				if(!this.region){
					this.$refs.uToast.show({
						title: '请选择地区'
					})
				}else if(!this.address){
					this.$refs.uToast.show({
						title: '请输入详细地址'
					})
				}else{
					let DetailedAddress = this.region+this.address
					let pages = getCurrentPages();  //获取所有页面栈实例列表
					let nowPage = pages[ pages.length - 1];  //当前页页面实例
					let prevPage = pages[ pages.length - 2 ];  //上一页页面实例
					prevPage.$vm.Address = DetailedAddress; 
					uni.navigateBack({
						delta:1
					})
				}
			}
		}
	}
</script>

<style scoped lang="less">
.StoreAddress{
	background-color: #F3F3F3;
	height: 100vh;
	overflow: auto;
	padding-top: 88upx;
	.preservationBtn{
		padding-right: 24upx;
		color: #FFAC3F;
		font-size: 32upx;
	}
	.StoreAddressBox{
		margin-top: 16upx;
		.toStoreAddressItem{
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 32upx 24upx;
			background-color: #fff;
			width: 750upx;
			border-bottom: 2upx solid #EDEDED;
			.addresstitle{
				font-size: 28upx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
			}
			.addressNameBox{
				display: flex;
				align-items: center;
				.addressName{
					font-size: 24upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #333333;
					margin-right: 8upx;
				}
			}
		}
		.specificAddressBox{
			display: flex;
			align-items: center;
			width: 750upx;
			background-color: #fff;
			padding: 32upx 24upx;
			.specifictitle{
				width: 140upx;
				font-size: 28upx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
			}
			.inputBox{
				width: calc(100% - 140upx);
				input{
					width: 100%;
					font-size: 24upx;
				}
			}
		}
	}
}
</style>
